<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" %>


<form class="form-horizontal row">
    <div class="col-sm-12" id="div_error"></div>
    <div class="form-group col-sm-5">
        <label class="col-sm-4 control-label">单位名称：</label>
        <div class="col-sm-8">
            <p class="form-control-static">${business.companyName}</p>
        </div>
    </div>

    <div class="form-group col-sm-5">
        <label class="col-sm-4 control-label">事　　项：</label>
        <div class="col-sm-8">
            <p class="form-control-static">${business.itemName}</p>
        </div>
    </div>
    <div class="form-group col-sm-5">
        <label class="col-sm-4 control-label">业务类型：</label>
        <div class="col-sm-8">
            <p class="form-control-static">${business.businessType}</p>
        </div>
    </div>
    <div class="form-group col-sm-5">
        <label class="col-sm-4 control-label">产品名称：</label>
        <div class="col-sm-8">
            <p class="form-control-static">${business.productName}</p>
        </div>
    </div>

    <div class="form-group  col-sm-12">
        <div class="col-sm-9 col-sm-offset-1">
            <table id="table_result"></table>
        </div>
    </div>

    <div class="form-group col-sm-5">
        <label class="col-sm-4 control-label">开始时间：</label>
        <div class="col-sm-8">
            <div class="input-group date form_date  timeInput">
                                                <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                <input class="form-control" type="text" id="startTime" value="">
            </div>
        </div>
    </div>

    <div class="form-group col-sm-5">
        <label class="col-sm-4 control-label">结束时间：</label>
        <div class="col-sm-8">
            <div class="input-group date form_date  timeInput">
                                                <span class="input-group-addon">
                                                    <span class="glyphicon glyphicon-calendar"></span>
                                                </span>
                <input class="form-control" type="text" id="endTime" value="">
            </div>
        </div>
    </div>




    <div class="form-group col-sm-5">
        <div class="col-sm-8 col-sm-offset-4">
            <button type="button" id="btn_submit" class="btn btn-default  btn-sm ">
                <span class="glyphicon glyphicon-ok"></span>&nbsp;提&nbsp;交&nbsp;
            </button>
        </div>
    </div>
</form>


<script>
    $("#btn_submit").click(function () {
        var data = $table_result.bootstrapTable('getOptions').data;
        var crowIdCardList = [], leaderIdCard;
        for (var i = 0; i < data.length; i++) {
            if (data[i].leader == true) {
                leaderIdCard = data[i].idCard;
            } else {
                crowIdCardList.push(data[i].idCard);
            }
        }
        if (!leaderIdCard) {
            alert("请选择一位组长");
            return;
        } else {
            console.log(crowIdCardList);
            console.log(leaderIdCard);
            $.sysPlugin.superAjax({
                data: {
                    crowIdCardList: crowIdCardList.toString(),
                    leaderIdCard: leaderIdCard,
                    businessCode: '${business.businessCode}',
                    startTime: $("#startTime").val(),
                    endTime: $("#endTime").val()
                },
                url: "${base}/httpPage/addBusinessExperts",
                operateType: 'insert',
                showSuccessAlert: true,
                showWarnAlert: false,
                successCall: function (data) {
                },
                errorCall: function (data) {
                    $.sysPlugin.errorCallBack(data, {
                        errorAddress: $("#div_error")
                    })
                }
            });
        }
    });


    $("#table_result").bootstrapTable({
        striped: true,
        uniqueId: "idCard",                     //每一行的唯一标识，一般为主键列
        columns: [
            {
                field: 'leader',
                radio: "true",
                formatter: function (value, row, index) {
                    $(".bs-checkbox .th-inner").html("组长");
                }
            },
            {
                title: '姓名',
                field: 'name',
                formatter: function (value, row, index) {
                    return [
                        '<div class="nameClick" ><a href="javascript:;" style="text-decoration: none ;display: block;width: 60px">' + value + '</a></div>'
                    ].join('');
                },
                events: 'events'
            },
            {
                field: 'idCard',
                title: '身份证号码'
            },
            {
                field: 'grade',
                title: '专家类型'
            },
            {
                field: 'phone',
                title: '手机号码'
            },
            {
                title: '操作',
                events: 'events',
                formatter: function (value, row, index) {
                    return [

                        '<button   type="button" class="btn btn-xs btn-default  unCheckExpert">' +
                        '<span class="glyphicon glyphicon-remove"></span> 取消' +
                        '</button>'

                    ].join('');
                }
            }
        ]
    });

</script>